{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c56cc6e3",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: http://mirrors.aliyun.com/pypi/simple/\n",
      "Collecting pandas\n",
      "  Downloading http://mirrors.aliyun.com/pypi/packages/d9/cd/f27c2992cbe05a3e39937f73a4be635a9ec149ec3ca4467d8cf039718994/pandas-1.5.3-cp310-cp310-win_amd64.whl (10.4 MB)\n",
      "     -------------------------------------- 10.4/10.4 MB 129.5 kB/s eta 0:00:00\n",
      "Requirement already satisfied: python-dateutil>=2.8.1 in c:\\users\\administrator\\appdata\\roaming\\python\\python310\\site-packages (from pandas) (2.8.2)\n",
      "Collecting numpy>=1.21.0\n",
      "  Downloading http://mirrors.aliyun.com/pypi/packages/fa/df/53e8c0c8ccecf360b827a3d2b1b6060644c635c3149a9d6415a6fe4ccf44/numpy-1.24.2-cp310-cp310-win_amd64.whl (14.8 MB)\n",
      "     -------------------------------------- 14.8/14.8 MB 129.0 kB/s eta 0:00:00\n",
      "Collecting pytz>=2020.1\n",
      "  Downloading http://mirrors.aliyun.com/pypi/packages/2e/09/fbd3c46dce130958ee8e0090f910f1fe39e502cc5ba0aadca1e8a2b932e5/pytz-2022.7.1-py2.py3-none-any.whl (499 kB)\n",
      "     ------------------------------------ 499.4/499.4 kB 137.3 kB/s eta 0:00:00\n",
      "Requirement already satisfied: six>=1.5 in d:\\program files (x86)\\thonny\\lib\\site-packages (from python-dateutil>=2.8.1->pandas) (1.16.0)\n",
      "Installing collected packages: pytz, numpy, pandas\n",
      "Successfully installed numpy-1.24.2 pandas-1.5.3 pytz-2022.7.1\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "  WARNING: The script f2py.exe is installed in 'D:\\Program Files (x86)\\Thonny\\Scripts' which is not on PATH.\n",
      "  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.\n",
      "\n",
      "[notice] A new release of pip available: 22.3.1 -> 23.0.1\n",
      "[notice] To update, run: python.exe -m pip install --upgrade pip\n"
     ]
    }
   ],
   "source": [
    "! python -m pip install pandas\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "8e70087d",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "abed6716",
   "metadata": {},
   "outputs": [],
   "source": [
    "a = r'D:\\jack\\all-b.csv'\n",
    "b = r'D:\\jack\\all-a.csv'\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "e1934e65",
   "metadata": {},
   "outputs": [],
   "source": [
    "datA = pd.read_csv(a,encoding='GBK')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "97bef719",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>编号</th>\n",
       "      <th>设备类型</th>\n",
       "      <th>激活状态</th>\n",
       "      <th>IP地址</th>\n",
       "      <th>子网掩码</th>\n",
       "      <th>IPv4网关</th>\n",
       "      <th>物理地址</th>\n",
       "      <th>端口</th>\n",
       "      <th>服务增强型端口</th>\n",
       "      <th>HTTP端口</th>\n",
       "      <th>...</th>\n",
       "      <th>启动时间</th>\n",
       "      <th>IPv6地址</th>\n",
       "      <th>IPv6网关</th>\n",
       "      <th>IPv6子网前缀长度</th>\n",
       "      <th>是否支持IPv6</th>\n",
       "      <th>是否支持修改IPv6</th>\n",
       "      <th>是否支持DHCP</th>\n",
       "      <th>IPv4 DHCP状态</th>\n",
       "      <th>支持萤石云</th>\n",
       "      <th>萤石云状态</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>DS-7816N-K2(D)</td>\n",
       "      <td>已激活</td>\n",
       "      <td>192.168.11.188</td>\n",
       "      <td>255.255.255.0</td>\n",
       "      <td>192.168.11.1</td>\n",
       "      <td>ac-b9-2f-24-23-84</td>\n",
       "      <td>8000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>80</td>\n",
       "      <td>...</td>\n",
       "      <td>2023-03-01 13:39:14</td>\n",
       "      <td>::</td>\n",
       "      <td>::</td>\n",
       "      <td>64</td>\n",
       "      <td>支持</td>\n",
       "      <td>支持</td>\n",
       "      <td>支持</td>\n",
       "      <td>关闭</td>\n",
       "      <td>支持</td>\n",
       "      <td>开启</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>DS-7808N-K1/8P(D)</td>\n",
       "      <td>已激活</td>\n",
       "      <td>192.168.34.244</td>\n",
       "      <td>255.255.255.0</td>\n",
       "      <td>192.168.34.1</td>\n",
       "      <td>c0-6d-ed-2c-d9-64</td>\n",
       "      <td>8000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>80</td>\n",
       "      <td>...</td>\n",
       "      <td>2023-03-01 07:42:03</td>\n",
       "      <td>fe80::c26d:edff:fe2c:d964</td>\n",
       "      <td>::</td>\n",
       "      <td>64</td>\n",
       "      <td>支持</td>\n",
       "      <td>支持</td>\n",
       "      <td>支持</td>\n",
       "      <td>关闭</td>\n",
       "      <td>支持</td>\n",
       "      <td>开启</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>DS-7832N-K2</td>\n",
       "      <td>已激活</td>\n",
       "      <td>192.168.88.254</td>\n",
       "      <td>255.255.255.0</td>\n",
       "      <td>192.168.88.1</td>\n",
       "      <td>68-6d-bc-f6-0e-91</td>\n",
       "      <td>8000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>80</td>\n",
       "      <td>...</td>\n",
       "      <td>2023-02-18 17:46:47</td>\n",
       "      <td>fe80::6a6d:bcff:fef6:e91</td>\n",
       "      <td>::</td>\n",
       "      <td>64</td>\n",
       "      <td>支持</td>\n",
       "      <td>支持</td>\n",
       "      <td>支持</td>\n",
       "      <td>关闭</td>\n",
       "      <td>支持</td>\n",
       "      <td>开启</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3 rows × 24 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   编号               设备类型 激活状态            IP地址           子网掩码        IPv4网关  \\\n",
       "0   1     DS-7816N-K2(D)  已激活  192.168.11.188  255.255.255.0  192.168.11.1   \n",
       "1   2  DS-7808N-K1/8P(D)  已激活  192.168.34.244  255.255.255.0  192.168.34.1   \n",
       "2   3        DS-7832N-K2  已激活  192.168.88.254  255.255.255.0  192.168.88.1   \n",
       "\n",
       "                物理地址    端口  服务增强型端口  HTTP端口  ...                 启动时间  \\\n",
       "0  ac-b9-2f-24-23-84  8000      NaN      80  ...  2023-03-01 13:39:14   \n",
       "1  c0-6d-ed-2c-d9-64  8000      NaN      80  ...  2023-03-01 07:42:03   \n",
       "2  68-6d-bc-f6-0e-91  8000      NaN      80  ...  2023-02-18 17:46:47   \n",
       "\n",
       "                      IPv6地址  IPv6网关 IPv6子网前缀长度 是否支持IPv6 是否支持修改IPv6 是否支持DHCP  \\\n",
       "0                         ::      ::         64       支持         支持       支持   \n",
       "1  fe80::c26d:edff:fe2c:d964      ::         64       支持         支持       支持   \n",
       "2   fe80::6a6d:bcff:fef6:e91      ::         64       支持         支持       支持   \n",
       "\n",
       "   IPv4 DHCP状态 支持萤石云 萤石云状态  \n",
       "0           关闭    支持    开启  \n",
       "1           关闭    支持    开启  \n",
       "2           关闭    支持    开启  \n",
       "\n",
       "[3 rows x 24 columns]"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datA.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "dc79b9e1",
   "metadata": {},
   "outputs": [],
   "source": [
    "datB= pd.read_csv(b,encoding='GBK')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "1d2245f4",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>编号</th>\n",
       "      <th>设备类型</th>\n",
       "      <th>激活状态</th>\n",
       "      <th>IP地址</th>\n",
       "      <th>子网掩码</th>\n",
       "      <th>IPv4网关</th>\n",
       "      <th>物理地址</th>\n",
       "      <th>端口</th>\n",
       "      <th>服务增强型端口</th>\n",
       "      <th>HTTP端口</th>\n",
       "      <th>...</th>\n",
       "      <th>启动时间</th>\n",
       "      <th>IPv6地址</th>\n",
       "      <th>IPv6网关</th>\n",
       "      <th>IPv6子网前缀长度</th>\n",
       "      <th>是否支持IPv6</th>\n",
       "      <th>是否支持修改IPv6</th>\n",
       "      <th>是否支持DHCP</th>\n",
       "      <th>IPv4 DHCP状态</th>\n",
       "      <th>支持萤石云</th>\n",
       "      <th>萤石云状态</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>DS-7816N-K2(D)</td>\n",
       "      <td>已激活</td>\n",
       "      <td>192.168.11.188</td>\n",
       "      <td>255.255.255.0</td>\n",
       "      <td>192.168.11.1</td>\n",
       "      <td>ac-b9-2f-24-23-84</td>\n",
       "      <td>8000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>80</td>\n",
       "      <td>...</td>\n",
       "      <td>2023-03-01 13:39:14</td>\n",
       "      <td>::</td>\n",
       "      <td>::</td>\n",
       "      <td>64</td>\n",
       "      <td>支持</td>\n",
       "      <td>支持</td>\n",
       "      <td>支持</td>\n",
       "      <td>关闭</td>\n",
       "      <td>支持</td>\n",
       "      <td>开启</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>DS-7832N-K2</td>\n",
       "      <td>已激活</td>\n",
       "      <td>192.168.17.249</td>\n",
       "      <td>255.255.255.0</td>\n",
       "      <td>192.168.17.1</td>\n",
       "      <td>84-9a-40-59-b2-73</td>\n",
       "      <td>8000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>80</td>\n",
       "      <td>...</td>\n",
       "      <td>2023-02-17 10:21:49</td>\n",
       "      <td>fe80::869a:40ff:fe59:b273</td>\n",
       "      <td>::</td>\n",
       "      <td>64</td>\n",
       "      <td>支持</td>\n",
       "      <td>支持</td>\n",
       "      <td>支持</td>\n",
       "      <td>关闭</td>\n",
       "      <td>支持</td>\n",
       "      <td>开启</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>DS-8632N-E8</td>\n",
       "      <td>已激活</td>\n",
       "      <td>192.168.87.250</td>\n",
       "      <td>255.255.255.0</td>\n",
       "      <td>192.168.87.1</td>\n",
       "      <td>8c-e7-48-6e-bf-80</td>\n",
       "      <td>8000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>80</td>\n",
       "      <td>...</td>\n",
       "      <td>2023-02-23 08:08:52</td>\n",
       "      <td>fe80::8ee7:48ff:fe6e:bf80</td>\n",
       "      <td>::</td>\n",
       "      <td>64</td>\n",
       "      <td>支持</td>\n",
       "      <td>支持</td>\n",
       "      <td>支持</td>\n",
       "      <td>关闭</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>3 rows × 24 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   编号            设备类型 激活状态            IP地址           子网掩码        IPv4网关  \\\n",
       "0   1  DS-7816N-K2(D)  已激活  192.168.11.188  255.255.255.0  192.168.11.1   \n",
       "1   2     DS-7832N-K2  已激活  192.168.17.249  255.255.255.0  192.168.17.1   \n",
       "2   3     DS-8632N-E8  已激活  192.168.87.250  255.255.255.0  192.168.87.1   \n",
       "\n",
       "                物理地址    端口  服务增强型端口  HTTP端口  ...                 启动时间  \\\n",
       "0  ac-b9-2f-24-23-84  8000      NaN      80  ...  2023-03-01 13:39:14   \n",
       "1  84-9a-40-59-b2-73  8000      NaN      80  ...  2023-02-17 10:21:49   \n",
       "2  8c-e7-48-6e-bf-80  8000      NaN      80  ...  2023-02-23 08:08:52   \n",
       "\n",
       "                      IPv6地址  IPv6网关 IPv6子网前缀长度 是否支持IPv6 是否支持修改IPv6 是否支持DHCP  \\\n",
       "0                         ::      ::         64       支持         支持       支持   \n",
       "1  fe80::869a:40ff:fe59:b273      ::         64       支持         支持       支持   \n",
       "2  fe80::8ee7:48ff:fe6e:bf80      ::         64       支持         支持       支持   \n",
       "\n",
       "   IPv4 DHCP状态 支持萤石云 萤石云状态  \n",
       "0           关闭    支持    开启  \n",
       "1           关闭    支持    开启  \n",
       "2           关闭   NaN   NaN  \n",
       "\n",
       "[3 rows x 24 columns]"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datB.head(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "2d1f78e3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'10-12-fb-7a-26-54'}"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "### 差集\n",
    "\n",
    "diff = set (datB['物理地址']).difference(set( datA['物理地址'] ))\n",
    "diff"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "b72c6ab6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>编号</th>\n",
       "      <th>设备类型</th>\n",
       "      <th>激活状态</th>\n",
       "      <th>IP地址</th>\n",
       "      <th>子网掩码</th>\n",
       "      <th>IPv4网关</th>\n",
       "      <th>物理地址</th>\n",
       "      <th>端口</th>\n",
       "      <th>服务增强型端口</th>\n",
       "      <th>HTTP端口</th>\n",
       "      <th>...</th>\n",
       "      <th>启动时间</th>\n",
       "      <th>IPv6地址</th>\n",
       "      <th>IPv6网关</th>\n",
       "      <th>IPv6子网前缀长度</th>\n",
       "      <th>是否支持IPv6</th>\n",
       "      <th>是否支持修改IPv6</th>\n",
       "      <th>是否支持DHCP</th>\n",
       "      <th>IPv4 DHCP状态</th>\n",
       "      <th>支持萤石云</th>\n",
       "      <th>萤石云状态</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>57</th>\n",
       "      <td>58</td>\n",
       "      <td>DS-IPC-B12HV2-IA</td>\n",
       "      <td>已激活</td>\n",
       "      <td>192.168.6.17</td>\n",
       "      <td>255.255.255.0</td>\n",
       "      <td>192.168.6.1</td>\n",
       "      <td>10-12-fb-7a-26-54</td>\n",
       "      <td>8000</td>\n",
       "      <td>NaN</td>\n",
       "      <td>80</td>\n",
       "      <td>...</td>\n",
       "      <td>1970-01-01 00:01:23</td>\n",
       "      <td>240e:390:2841:7df1:1212:fbff:fe7a:2654</td>\n",
       "      <td>::</td>\n",
       "      <td>64</td>\n",
       "      <td>支持</td>\n",
       "      <td>支持</td>\n",
       "      <td>支持</td>\n",
       "      <td>关闭</td>\n",
       "      <td>支持</td>\n",
       "      <td>开启</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>1 rows × 24 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "    编号              设备类型 激活状态          IP地址           子网掩码       IPv4网关  \\\n",
       "57  58  DS-IPC-B12HV2-IA  已激活  192.168.6.17  255.255.255.0  192.168.6.1   \n",
       "\n",
       "                 物理地址    端口  服务增强型端口  HTTP端口  ...                 启动时间  \\\n",
       "57  10-12-fb-7a-26-54  8000      NaN      80  ...  1970-01-01 00:01:23   \n",
       "\n",
       "                                    IPv6地址  IPv6网关 IPv6子网前缀长度 是否支持IPv6  \\\n",
       "57  240e:390:2841:7df1:1212:fbff:fe7a:2654      ::         64       支持   \n",
       "\n",
       "   是否支持修改IPv6 是否支持DHCP  IPv4 DHCP状态 支持萤石云 萤石云状态  \n",
       "57         支持       支持           关闭    支持    开启  \n",
       "\n",
       "[1 rows x 24 columns]"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "datB.loc[ datB['物理地址'].isin(diff) ]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a2943976",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
